package private1;
public class Student {
    private String name;
    private int age;

   // public void setName(String n) {
     //   name = n;
   // }


    public void setName(String name) {
        //name = name;
        this.name=name;
        //this.name这里指代成员变量,最开始的name这个变量
        //name是方法中的形参
        //局部变量与成员变量同名用this.
    }

    public String getName() {
        return name;
    }

    public void setAge(int age) {
        if (age < 0 || age > 120) {
            System.out.println("您输入的信息有误");
        } else {
            this.age= age;
        }
    }

    public int getAge() {
        return age;
    }

    public void show() {
        System.out.println(name + "," + age);
    }

}